package com.syl.auth.config;

import lombok.Data;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @ClassName SmallSecurityProperties
 * @Description 可配置security属性
 * @Author YunLong
 * @Date 2023/4/26 21:37
 */
@Configuration
@ConfigurationProperties("small-security")
@Data
public class SmallSecurityProperties {
    /**
     * 令牌密钥
     */
    private String jwtSecret = "small-security";

    /**
     * 令牌过期时间
     */
    private Long expiration = 60 * 24 * 30L;

    /**
     * 登录接口 Url
     */
    private String loginUrl = "/web/login";

    /**
     * 认证失败错误码
     */
    private String authenticationFailedCode = "000001";

    /**
     * 无权限访问错误码
     */
    private String permissionDeniedCode = "000002";

    /**
     * 未认证错误码
     */
    private String unauthorizedCode = "000003";

    /**
     * 无需认证即可访问的地址
     */
    private List<String> notLoginUrls = new ArrayList<>();

    /**
     * 需放行的前端静态资源地址
     */
    private List<String> staticResourceUrls = Arrays.asList("/css/**", "/js/**", "/index.html", "/img/**",
            "/fonts/**", "/favicon.ico");

    /**
     * Url 中包含此值，即意味无需登录即可访问
     */
    private String notLoginSign;

    /**
     * 未配置角色的Url 是否放行？
     */
    private boolean noRolesPass = true;

}
